import {
  q as t,
  p as O,
  ap as F,
  X as b,
  f as H,
  H as P,
  av as _,
  aw as j,
  k as q,
  m as E,
  l as G,
  az as X,
  as as l,
  aG as Y,
  at as m
} from "./index-b50e6ef9.js";
import { f as x } from "./finance-81050a55.js";
function Q(W) {
  const c = t([]),
    s = t(!0);
  t({}), O();
  const v = t(1),
    p = t(10),
    w = t(""),
    a = t([]),
    r = t(),
    y = t(""),
    C = F("reload"),
    g = b({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    S = b({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "赠送者昵称", prop: "send_name", minWidth: 80 },
      { label: "赠送者手机号", prop: "send_phone", minWidth: 100 },
      { label: "接收者昵称", prop: "get_name", minWidth: 80 },
      { label: "接收者手机号", prop: "get_phone", minWidth: 150 },
      { label: "赠送者初始积分", prop: "send_money", minWidth: 80 },
      { label: "接收者id", prop: "get_user_id", minWidth: 80 },
      { label: "接收者初始积分", prop: "get_money", minWidth: 80 },
      { label: "积分", prop: "money", minWidth: 100 },
      {
        label: "备注",
        prop: "content",
        minWidth: 250,
        formatter: ({ content: e }) =>
          e ||
          q(
            G("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [E("暂无")] }
          )
      },
      { label: "创建时间", prop: "create_time", minWidth: 180 }
    ],
    D = H(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function z(e) {
    X(e);
  }
  async function I(e) {
    const n = { role_id: e.role_id },
      d = JSON.stringify(n),
      f = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(d)) },
      i = await Y(f);
    i.code == 200
      ? (m("删除成功", { type: "success" }), C())
      : m(i.msg, { type: "error" });
  }
  function J() {}
  function k(e) {
    (p.value = e), h(void 0, e);
  }
  function L(e) {
    (v.value = e), h(e, void 0);
  }
  function N(e) {}
  function U(e) {
    (S.text = `正在加载第${e}页...`),
      (s.value = !0),
      _(600).then(() => {
        s.value = !1;
      });
  }
  async function R(e, n = []) {
    (a.value = []),
      n == null ||
        n.map(M => {
          const T = M,
            A = new Date(T);
          a.value.push(
            A.toLocaleDateString("zh-CN", {
              year: "numeric",
              month: "2-digit",
              day: "2-digit"
            })
          );
        }),
      (r.value = e),
      (s.value = !0),
      (w.value = e.user_phone),
      (y.value = e.type);
    const d = {
        page: 1,
        pagesize: p.value,
        content: "give",
        user_phone: r.value ? r.value.user_phone : void 0,
        type: e.type,
        start: a.value[0],
        end: a.value[1]
      },
      u = JSON.stringify(d),
      i = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(u)) },
      { data: o } = await x(i);
    (c.value = o.give.data),
      (g.total = o.give.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function h(e = v.value, n = p.value) {
    const d = {
        page: e,
        pagesize: n,
        content: "give",
        user_phone: r.value ? r.value.user_phone : void 0,
        type: y.value || void 0,
        start: a.value[0],
        end: a.value[1]
      },
      u = JSON.stringify(d),
      i = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(u)) },
      o = await x(i);
    o.code === 200
      ? ((c.value = o.data.give.data),
        (g.total = o.data.give.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : m(o.msg, { type: "error" });
  }
  const V = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    P(() => {
      _().then(() => {
        const { setWatermark: e } = j(W.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        h();
    }),
    {
      loading: s,
      columns: B,
      dataList: c,
      pagination: g,
      buttonClass: D,
      formattedDate: a,
      onSearch: R,
      resetForm: V,
      handleaddUser: J,
      handleUpdate: z,
      handleDelete: I,
      handleSizeChange: k,
      handleCurrentChange: L,
      handleSelectionChange: N,
      onCurrentChange: U
    }
  );
}
export { Q as useRole };
